﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using System.Text;
using System.Xml;
using HRM.HRMServiceProxy;
using System.Globalization;

namespace HRM
{
    public class UIParamater
    {
        public static string TitleProject = "HRM";
        public static int pageSize = 25;

        public static int PAGE_SIZE_MAX = 9999;

        public static string Phay2So = "#,##0";
        public static string Cham2So = "#0.0#";
        public static string Cham3So = "#0.0##";
        public static int TIME_MOVE_UP = 500;//thời gian thông báo chạy lên
        public static int TIME_SHOW = 5000;//thời gian thông báo dừng
        public static int TIME_MOVE_DOWN = 500;//thời gian thông báo chạy xuống

        public static string CompanyName = "Công ty cổ phần dịch vụ kỹ thuật tin học và truyền thông - ISE";//Tên cty sử dụng phần mềm

        //public static DateTime UNDER_DATE = DateTime.ParseExact("01/01/2000", "dd/MM/yyyy", null);
        public static DateTime UNDER_DATE = DateTime.ParseExact("01/01/2000", "dd/MM/yyyy", CultureInfo.InvariantCulture);
        
        
        //public static DateTime END_DATE = DateTime.ParseExact("31/12/2020", "dd/MM/yyyy", null);
        public static DateTime END_DATE = DateTime.ParseExact("31/12/2020", "dd/MM/yyyy", CultureInfo.InvariantCulture);

        public static RoleRightInfo Quyen_HoSoCanBo;
        public static RoleRightInfo Quyen_NgayNghiVaCongTac;
        public static RoleRightInfo Quyen_BangPhanCa;
        public static RoleRightInfo Quyen_CacDeTaiKhoaHoc;
        public static RoleRightInfo Quyen_CacKhoaDaoTao;
        public static RoleRightInfo Quyen_CanhBaoNangLuong;
        public static RoleRightInfo Quyen_CanhBaoSapNghiHuu;
        public static RoleRightInfo Quyen_CanhBaoSapSinhNhat;
        public static RoleRightInfo Quyen_BangLuong;
        public static RoleRightInfo Quyen_BangChamCong;
        public static RoleRightInfo Quyen_DeNghiTroCap;
        public static RoleRightInfo Quyen_DoiChieuQuyBHXH;
        public static RoleRightInfo Quyen_TamUngLuong;
        public static RoleRightInfo Quyen_TruyDongBHXH;
        public static RoleRightInfo Quyen_KhenThuong;
        public static RoleRightInfo Quyen_DotTuyenDung;
        public static RoleRightInfo Quyen_UngVien;
        public static RoleRightInfo Quyen_ThamSoHeThong;
        public static RoleRightInfo Quyen_ChiNhanh;
        public static RoleRightInfo Quyen_PhongBan;
        public static RoleRightInfo Quyen_ChucVu;
        public static RoleRightInfo Quyen_CapDo;
        public static RoleRightInfo Quyen_NgoaiNgu;
        public static RoleRightInfo Quyen_DanToc;
        public static RoleRightInfo Quyen_TonGiao;

        public static RoleRightInfo Quyen_TinhTrangHonNhan;
        public static RoleRightInfo Quyen_LoaiHopDong;
        public static RoleRightInfo Quyen_HinhThucNghi;
        public static RoleRightInfo Quyen_CaLamViec;
        public static RoleRightInfo Quyen_LaiSuatChamNop;
        public static RoleRightInfo Quyen_NgayNghiTrongNam;
        public static RoleRightInfo Quyen_BaoCaoNhanSu;
        public static RoleRightInfo Quyen_BaoCaoTuyenDung;
        public static RoleRightInfo Quyen_BaoCaoBHXH;
        public static RoleRightInfo Quyen_BaoCaoHuongTroCap;
        public static RoleRightInfo Quyen_Bac;
        public static RoleRightInfo Quyen_NgachBac;
        public static RoleRightInfo Quyen_TrinhDo;
        public static RoleRightInfo Quyen_TieuChiDanhGia;
        public static RoleRightInfo Quyen_QuocGia;
        public static RoleRightInfo Quyen_HinhThucNghiViec;
        public static RoleRightInfo Quyen_ThietBiCCLD;
        public static RoleRightInfo Quyen_NhanVienNghiViec;
        public static RoleRightInfo Quyen_DeNghiCapSoBH;
        public static RoleRightInfo Quyen_DieuChinhSoBH;
        public static RoleRightInfo Quyen_PhatSinhBaoHiem;
        public static RoleRightInfo Quyen_ImportDuLieuCQBH;
        public static RoleRightInfo Quyen_UNC;

        public static RoleRightInfo Quyen_TinhThanhPho;
        public static RoleRightInfo Quyen_NoiKhamChuaBenh;
        public static RoleRightInfo Quyen_NghiepVuBaoHiem;
        public static RoleRightInfo Quyen_TyLeThuBaoHiem;
        public static RoleRightInfo Quyen_MucLuongToiThieu;

        public static int Employee_NotActive = 0;//Nhân viên đã thôi việc
        public static int Employee_LCInvalid = 1;//Nhân viên hết hạn hợp đồng
        public static int Employee_LCNearInvalid = 2;//Nhân viên sắp hệt hạn hợp đồng
        public static int Employee_Probation = 7;//NV thu viec hoc viec, thoi vụ
        public static int Employee_NoLC = 3;//Nhân viên không có hợp đồng
        public static int Employee_LCProbationInvalid = 4;//Nhân viên hết hạn thử việc
        public static int Employee_LCNearProbationInvalid = 5;//Nhân viên sắp hết hạn thử việc
        public static int Employee_Active = 6;//Nhân viên đang làm việc
        public static int Employee_NotFinish = 7;//Nhân viên chưa hòa thiện hồ sơ

        public static string FullNameOfUser="";

        public static int HetHanHD = 0;
        public static int SapHetHanHD = 0;
        public static int ChuaCoHD = 0;
        public static int HetHanTV = 0;
        public static int SapHetHanTV = 0;
        public static int SapHetHDDacBiet = 0;
      
    }


    public class ProxyConfig
    {

        //Cấu hình địa chỉ cho service
        public static EndpointAddress MainService = new EndpointAddress(Properties.Settings.Default.ServiceAddress);
        public static EndpointAddress Branch = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Branch");
        public static EndpointAddress Candidate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Candidate");
        public static EndpointAddress CR = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CR");
        public static EndpointAddress CC = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CC");
        public static EndpointAddress CWB = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CWB");
        public static EndpointAddress CFamily = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CFamily");
        public static EndpointAddress CLanguage = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CLanguage");
        public static EndpointAddress CInterview = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CInterview");
        public static EndpointAddress CCriteria = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CCriteria");
        public static EndpointAddress Certificate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Certificate");
        public static EndpointAddress ContractType = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_ContractType");
        public static EndpointAddress Department = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Department");
        public static EndpointAddress Employee = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Employee");
        public static EndpointAddress Ethnic = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Ethnic");
        public static EndpointAddress Family = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Family");
        public static EndpointAddress Grade = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Grade");
        public static EndpointAddress LabourContract = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LabourContract");
        public static EndpointAddress LabourLanguage = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LabourLanguage");
        public static EndpointAddress Language = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Language");
        public static EndpointAddress MaritalStatus = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MaritalStatus");
        public static EndpointAddress Position = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Position");
        public static EndpointAddress PositionDetail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_PositionDetail");
        public static EndpointAddress Recruitment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Recruitment");
        public static EndpointAddress Religion = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Religion");
        public static EndpointAddress WorkingBackground = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_WorkingBackground");
        public static EndpointAddress Comment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Comment");
        public static EndpointAddress RewardDiscipline = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_RewardDiscipline");
        public static EndpointAddress CheckTime = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CheckTime");
        public static EndpointAddress Leave = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Leave");
        public static EndpointAddress LeaveWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LeaveWork");
        public static EndpointAddress Shift = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Shift");
        public static EndpointAddress EmployeeShift = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EmployeeShift");
        public static EndpointAddress MarkWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MarkWork");
        public static EndpointAddress Salary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Salary");
        public static EndpointAddress Parameter = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Parameter");
        public static EndpointAddress Pensioner = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Pensioner");
        public static EndpointAddress Premium = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Premium");
        public static EndpointAddress Science = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Science");
        public static EndpointAddress User = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_User");
        public static EndpointAddress RoleRight = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_RoleRight");
        public static EndpointAddress Education = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Education");
        public static EndpointAddress FundSalary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_FundSalary");
        public static EndpointAddress InterestRate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_InterestRate");
        public static EndpointAddress SalaryFund = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SalaryFund");
        public static EndpointAddress AdvancePayment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_AdvancePayment");
        public static EndpointAddress LaterInsurance = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LaterInsurance");
        public static EndpointAddress Award = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Award");
        public static EndpointAddress Holiday = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Holiday");
        public static EndpointAddress Tax = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Tax");
        public static EndpointAddress Visa = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Visa");
        public static EndpointAddress National = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_National");
        public static EndpointAddress ServiceCharge = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_ServiceCharge");
        public static EndpointAddress SCD = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SCD");
        public static EndpointAddress EvaluationCriteria = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EvaluationCriteria");
        public static EndpointAddress MisConduct = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MisConduct");
        public static EndpointAddress LeaveRecord = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LeaveRecord");
        public static EndpointAddress SafetyDevice = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SafetyDevice");
        public static EndpointAddress SalaryAllowance = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SalaryAllowance");
        public static EndpointAddress Level = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Level");
        public static EndpointAddress GradeDetail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_GradeDetail");
        public static EndpointAddress Mtom = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/Mtom");
        public static EndpointAddress Standard = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Standard");
        public static EndpointAddress TypeOfLeaveWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_TypeOfLeaveWork");
        public static EndpointAddress IssueInsBook = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_IssueInsBook");
        public static EndpointAddress EditInsBook = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EditInsBook");
        public static EndpointAddress DoiSo = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_DoiSo");

        public static EndpointAddress Region = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Region");
        public static EndpointAddress Hospital = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Hospital");
        public static EndpointAddress Rate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Rate");
        public static EndpointAddress BasicSalary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_BasicSalary");
        public static EndpointAddress InsType = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_InsType");
        public static EndpointAddress Header = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Header");
        public static EndpointAddress Detail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Detail");
        public static EndpointAddress UNC = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_UNC");
        
        public static void ReNewAddress()
        {
            MainService = new EndpointAddress(Properties.Settings.Default.ServiceAddress);
            Branch = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Branch");
            Candidate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Candidate");
            CR = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CR");
            CC = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CC");
            CWB = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CWB");
            CFamily = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CFamily");
            CLanguage = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CLanguage");
            CInterview = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CInterview");
            CCriteria = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CCriteria");
            Certificate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Certificate");
            ContractType = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_ContractType");
            Department = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Department");
            Employee = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Employee");
            Ethnic = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Ethnic");
            Family = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Family");
            Grade = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Grade");
            LabourContract = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LabourContract");
            LabourLanguage = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LabourLanguage");
            Language = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Language");
            MaritalStatus = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MaritalStatus");
            Position = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Position");
            PositionDetail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_PositionDetail");
            Recruitment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Recruitment");
            Religion = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Religion");
            WorkingBackground = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_WorkingBackground");
            Comment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Comment");
            RewardDiscipline = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_RewardDiscipline");
            CheckTime = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_CheckTime");
            Leave = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Leave");
            LeaveWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LeaveWork");
            Shift = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Shift");
            EmployeeShift = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EmployeeShift");
            MarkWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MarkWork");
            Salary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Salary");
            Parameter = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Parameter");
            Pensioner = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Pensioner");
            Premium = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Premium");
            Science = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Science");
            User = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_User");
            RoleRight = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_RoleRight");
            Education = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Education");
            FundSalary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_FundSalary");
            InterestRate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_InterestRate");
            SalaryFund = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SalaryFund");
            AdvancePayment = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_AdvancePayment");
            LaterInsurance = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LaterInsurance");
            Award = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Award");
            Holiday = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Holiday");
            Tax = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Tax");
            Visa = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Visa");
            National = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_National");
            ServiceCharge = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_ServiceCharge");
            SCD = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SCD");
            EvaluationCriteria = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EvaluationCriteria");
            MisConduct = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_MisConduct");
            LeaveRecord = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_LeaveRecord");
            SafetyDevice = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SafetyDevice");
            SalaryAllowance = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_SalaryAllowance");
            Level = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Level");
            GradeDetail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_GradeDetail");
            Mtom = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/Mtom");
            Standard = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Standard");
            TypeOfLeaveWork = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_TypeOfLeaveWork");
            IssueInsBook = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_IssueInsBook");
            EditInsBook = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_EditInsBook");
            Header = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Header");
            Detail = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Detail");
            Region = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Region");
            Hospital = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Hospital");
            Rate = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_Rate");
            BasicSalary = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_BasicSalary");
            InsType = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_InsType");
            UNC = new EndpointAddress(Properties.Settings.Default.ServiceAddress + "/HRM_UNC");
            
        }

        //Cấu hình Binding
        public static Binding GetBinding()
        {
            WSHttpBinding WsHttpBinding = new WSHttpBinding();
            NetTcpBinding NetTCPBinding = new NetTcpBinding();
            TimeSpan span = new TimeSpan(0, 3, 0);
            if (Properties.Settings.Default.ServiceAddress.Contains("net.tcp://"))
            {
                NetTCPBinding.Name = "Binding";
                NetTCPBinding.CloseTimeout = span;
                NetTCPBinding.OpenTimeout = span;
                NetTCPBinding.ReceiveTimeout = span;
                NetTCPBinding.SendTimeout = span;
                NetTCPBinding.TransactionFlow = false;
                NetTCPBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                NetTCPBinding.MaxBufferPoolSize = 2147483647;
                NetTCPBinding.MaxReceivedMessageSize = 2147483647;
                NetTCPBinding.ReaderQuotas = new XmlDictionaryReaderQuotas();
                NetTCPBinding.ReaderQuotas.MaxDepth = 32;
                NetTCPBinding.ReaderQuotas.MaxStringContentLength = 8192;
                NetTCPBinding.ReaderQuotas.MaxArrayLength = 16384;
                NetTCPBinding.ReaderQuotas.MaxBytesPerRead = 4096;
                NetTCPBinding.ReaderQuotas.MaxNameTableCharCount = 16384;
                NetTCPBinding.Security.Mode = SecurityMode.None;
                NetTCPBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
                NetTCPBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
                NetTCPBinding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
                return NetTCPBinding;
            }
            else
            {
                string proxyIpAddress = Properties.Settings.Default.ProxyAddress;
                int proxyPort = Convert.ToInt32(Properties.Settings.Default.ProxyPort);

                //if (Properties.Settings.Default.UseProxy)
                //{
                //    BasicHttpBinding binding = new BasicHttpBinding("wsHttpBinding"); /* Binding is the name of the binding element in the app.config */
                //    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                //    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
                //    binding.UseDefaultWebProxy = false;
                //    binding.ProxyAddress = new Uri(string.Format("http://{0}:{1}", proxyIpAddress, proxyPort));
                //    return binding;
                //}
                //else
                //{
                    WsHttpBinding.Name = "Binding";
                    WsHttpBinding.CloseTimeout = span;
                    WsHttpBinding.OpenTimeout = span;
                    WsHttpBinding.ReceiveTimeout = span;
                    WsHttpBinding.SendTimeout = span;
                    WsHttpBinding.TransactionFlow = false;
                    WsHttpBinding.BypassProxyOnLocal = false;
                    WsHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                    WsHttpBinding.MaxBufferPoolSize = 2147483647;
                    WsHttpBinding.MaxReceivedMessageSize = 2147483647;
                    WsHttpBinding.MessageEncoding = WSMessageEncoding.Text;
                    WsHttpBinding.TextEncoding = Encoding.UTF8;
                    
                    //nếu gọi qua proxy
                    //WsHttpBinding.UseDefaultWebProxy = true;
                    WsHttpBinding.UseDefaultWebProxy = !Properties.Settings.Default.UseProxy;
                    
                    //
                    WsHttpBinding.ReaderQuotas = new XmlDictionaryReaderQuotas();
                    WsHttpBinding.ReaderQuotas.MaxDepth = 32;
                    WsHttpBinding.ReaderQuotas.MaxStringContentLength = 16384;
                    WsHttpBinding.ReaderQuotas.MaxArrayLength = 2147483647;
                    WsHttpBinding.ReaderQuotas.MaxBytesPerRead = 16384;
                    WsHttpBinding.ReaderQuotas.MaxNameTableCharCount = 16384;
                    
                    //
                    //WsHttpBinding.Security.Mode = SecurityMode.None;
                    WsHttpBinding.Security.Mode = (Properties.Settings.Default.UseProxy ? SecurityMode.None : SecurityMode.None);
                    //
                    //WsHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                    WsHttpBinding.Security.Transport.ClientCredentialType = (Properties.Settings.Default.UseProxy ? HttpClientCredentialType.Basic : HttpClientCredentialType.None);

                    //
                    //WsHttpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                    WsHttpBinding.Security.Transport.ProxyCredentialType = (Properties.Settings.Default.UseProxy ? HttpProxyCredentialType.Basic : HttpProxyCredentialType.None);

                    //
                    if (Properties.Settings.Default.UseProxy)
                    {
                        WsHttpBinding.ProxyAddress = new Uri(string.Format("http://{0}:{1}", proxyIpAddress, proxyPort));
                    }

                    //
                    WsHttpBinding.Security.Transport.Realm = string.Empty;
                    WsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
                    WsHttpBinding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
                    WsHttpBinding.Security.Message.NegotiateServiceCredential = false;
                    return WsHttpBinding;
                //}
            }
        }
    }

    public class Message
    {
       
        public static string NewPwdOtherOldPwd = UpdateUI.GetString("matkhauvakhangdinhmatkhaukhongkhop");
        public static string Confirm_Pwd_IsEmpty = UpdateUI.GetString("chuanhapmatkhaukhangdinh");
        public static string New_Pwd_IsEmpty = UpdateUI.GetString("chuanhapmatkhaumoi");
        public static string Old_Pwd_Invalid = UpdateUI.GetString("matkhaucusai");
        public static string UserName_Invalid = UpdateUI.GetString("tendangnhapsai");
        public static string Pasword_Invalid = UpdateUI.GetString("matkhausai");//
        public static string Uid_Pwd_Invalid = UpdateUI.GetString("tendangnhapvamatkhausai");
        public static string Change_Password_Success = UpdateUI.GetString("doimatkhauthanhcong");
        public static string No_Change_Password = UpdateUI.GetString("khongdoiduocmatkhau");
        public static string Username_IsEmpty = UpdateUI.GetString("chuanhaptendangnhap");
        public static string Username_IsExist = UpdateUI.GetString("datontaitendangnhap");
        public static string Password_IsEmpty = UpdateUI.GetString("chuanhapmatkhau");
        public static string Branch_IsEmpty = UpdateUI.GetString("phaichonchinhanh");
        public static string Department_IsEmpty = UpdateUI.GetString("phaichonphongban"); 
        
        
    }


}
